package so.ifl.servcie.impl;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import so.ifl.commons.tools.Constant;
import so.ifl.dao.OfficeInfoDao;
import so.ifl.dao.SysDao;
import so.ifl.servcie.OfficeService;
import so.ifl.vo.OfficeVo;

/**
 * 
 * create by simon
 * create at 2012-1-8 下午2:03:44
 * <mailto:liangyuanliu@gmail.com>
 */
@Service("officeService")
public class OfficeServiceImpl implements OfficeService {

	@Autowired
	private OfficeInfoDao officeInfoDao;
	
	@Autowired
	private SysDao sysDao;

	@Override
	public List<OfficeVo> queryOfficeWithParamAndPagination(
			Map<String, Object> params, Integer offset, Integer limit) {

		return officeInfoDao.queryOfficeWithParamAndPagination(params,
				new RowBounds(offset, limit));
	}

	@Override
	public int countOfficeWithParam(Map<String, Object> param) {
		return officeInfoDao.countOfficeWithParam(param);
	}

	@Override
	public void insertOffice(OfficeVo officeVo) {
		String seq = sysDao.getSeq(Constant.JXT_OFFICE_SEQ);
		officeVo.setOfficeCode(seq);//生成编号
		officeInfoDao.insertOffice(officeVo);

	}

	@Override
	public void updateOffice(OfficeVo officeVo) {
		officeInfoDao.updateOffice(officeVo);
	}

	@Override
	public void deleteOffice(Integer officeId) {
		officeInfoDao.deleteOffice(officeId);
	}
	
	/**
	 * 
	 * create by aaron.lu
	 * create at 2012-4-14 上午12:39:44
	 * <mailto: atyuan.lu@gmail.com>
	 * @param params
	 * @return
	 *
	 */
	public List<OfficeVo> queryOfficeByStudent(Map<String, Object> params){
		return officeInfoDao.queryOfficeByStudent(params);
	}

}
